package org.example.device.remote.failback;

import lombok.extern.slf4j.Slf4j;
import org.example.device.remote.DeviceInfoFeignService;
import org.example.device.remote.entity.DeviceResp;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @version: 1.00.00
 * @description: IOT3.0feign调用分组组件类熔断
 * @copyright: Copyright (c) 2020 立林科技 All Rights Reserved
 * @company: 厦门立林科技有限公司
 * @author: youxiaojuan
 * @date: 2020-3-11 16:00:26
 */
@Component
@Slf4j
public class DeviceInfoFeignServiceHystrix implements FallbackFactory<DeviceInfoFeignService> {


    @Override
    public DeviceInfoFeignService create(Throwable cause) {
        log.error("${spring.application.name} fallback; reason was:{}", cause.getMessage());
        return new DeviceInfoFeignService() {
            @Override
            public DeviceResp queryDevice(String id, String groupId) {
                return null;
            }
        };
    }

}
